package com.ch.swagger2.controller.user;

import com.ch.swagger2.model.Component;
import com.ch.swagger2.model.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @author cj-ch
 * @date 2018/5/3 上午10:50
 */
@RestController
@RequestMapping("/basic/component")
@Api(value = "用户权限接口",tags = "用户")
public class ComponentController {

    static List<Component> components;
    static {
        components = new ArrayList<>(16);
        components.add(new Component(1L,"A权限"));
        components.add(new Component(2L,"B权限"));
        components.add(new Component(3L,"C权限"));
    }

    @ApiOperation(value = "根据用户Id查询用户权限",notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",value = "用户ID",required = true,paramType = "path",dataType = "Long")
    })
    @GetMapping("/query-list/{id}")
    public Response<List<Component>> listByUserId(@PathVariable Long id){
        System.out.println("根据用户Id{"+id+"}查询用户权限");
        return Response.success(components);
    }
}
